            
class FloorController {
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only
    // accept POST requests
    def allowedMethods = [delete:'POST',
                          save:'POST',
                          update:'POST']

    def list = {
        if(!params.max)params.max = 10
        [ floorList: Floor.list( params ) ]
    }

    def show = {
        [ floor : Floor.get( params.id ) ]
    }

    def delete = {
        def floor = Floor.get( params.id )
        if(floor) {
            floor.delete()
            flash.message = "Floor ${params.id} deleted."
            redirect(action:list)
        }
        else {
            flash.message = "Floor not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def floor = Floor.get( params.id )

        if(!floor) {
                flash.message = "Floor not found with id ${params.id}"
                redirect(action:list)
        }
        else {
            return [ floor : floor ]
        }
    }

    def update = {
        def floor = Floor.get( params.id )
        if(floor) {
             floor.properties = params
            if(floor.save()) {
                redirect(action:show,id:floor.id)
            }
            else {
                render(view:'edit',model:[floor:floor])
            }
        }
        else {
            flash.message = "Floor not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def floor = new Floor()
        floor.properties = params
        return ['floor':floor]
    }

    def save = {
        def floor = new Floor()
        floor.properties = params
        if(floor.save()) {
            redirect(action:show,id:floor.id)
        }
        else {
            render(view:'create',model:[floor:floor])
        }
    }

}